<template>
  <tiny-checkbox
      style="margin-left: 10px;"
      :size="size"
      v-model="model"
      :false-label="0"
      :true-label="1"
      @change="change">{{label}}</tiny-checkbox>
</template>
<script setup>
import {ref} from "vue";
const emit = defineEmits(['change'])
import {TinyCheckbox} from "@opentiny/vue";

const props = defineProps({
  inject: {type: Boolean, default: false},
  label: {type: String, default: ''},
  size: {type: String, default: ''},
})
const fApi = ref({})
const model = defineModel()
const change = (val) => {
  if(props.inject) {
    emit('change', fApi.value, val)
  }
  else {
    emit('change', val)
  }
}

const setApi = (api) => {
  fApi.value = api
}
defineExpose({setApi})
</script>